package com.xzc.spring5.service;

import com.xzc.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import sun.misc.Contended;

import javax.annotation.Resource;
import java.security.Key;
import java.util.List;
import java.util.Map;

/**
 * @author 徐州城
 * @version 1.0
 */

//在注解里面的value属性值可以省略不写，
//默认值是 类名称首字母变小写
//UserService -- userService
@Service  //和<bean id="userService" class=""/> 一样
public class UserService {

    @Value(value = "abc")//value：注入属性的值
    private String name;
    @Value(value = "list")
    private List<String> list;
    //定义dao类型属性
    //不需要添加set()，在底层spring封装了
    //添加注入属性注解
//    @Autowired
//    @Qualifier(value = "userDaoImpl1")//根据指定类或子类的注解 value值进行注入，@Repository(value = "userDaoImpl1")
//    private UserDao userDao;

    //@Resource //根据类型进行注入
    @Resource(name = "userDaoImpl1") //根据名称进行注入
    private UserDao userDao;

    public void add(){
        System.out.println("service add... " + name + list);
        userDao.add();
    }
}
